home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / backup < prev    next >
Text File  |  1995-03-31  |  8KB  |  292 lines

  1. Article 5677 of comp.sys.handhelds:
  2. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!uakari.primate.wisc.edu!sdd.hp.com!hplabs!hpl-opus!hpnmdla!darrylo
  3. From: darrylo@hpnmdla.hp.com (Darryl Okahata)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: How to backup the ENTIRE HP-48SX memory
  6. Message-ID: <1570023@hpnmdla.hp.com>
  7. Date: 8 Apr 91 08:12:16 GMT
  8. Organization: HP Network Measurements Div, Santa Rosa, CA
  9. Lines: 279
  10.  
  11.  
  12.      Here is a beta-release of a program to backup the ENTIRE contents
  13. (libs and all) of an HP-48SX.  It's not perfect, it's huge (about 1000
  14. bytes), and it's probably inefficient (I just slapped this together).
  15.  
  16.      Also, while I've tried to work out any bugs, there's no guarantee
  17. that it works.  ;-)
  18.  
  19.      The big advantage of these functions, over previously-released
  20. ones, is that you only need as much memory as the largest library/port
  21. variable to do a backup, as the libraries/port variables are saved in
  22. separate files and not as a concatenated list in main memory.
  23.  
  24.      The code at the end of this message contains two functions: BACKUP
  25. and RECOVER.  In order to use these functions, you need to backup to a
  26. kermit SERVER; you must place the destination machine in kermit SERVER
  27. mode to use these routines.  If you do not have a kermit that supports
  28. SERVER mode, you cannot use these routines.  You must also use binary
  29. transfer mode; if you accidentally use ASCII mode, the transfer will
  30. take hours.  Also, the clock display must be turned off, due to the
  31. archive bug; if the display is turned on, the clock will be turned off,
  32. and you will be asked to redo the operation.
  33.  
  34.      You press BACKUP to archive the contents of your HP-48SX.  BACKUP
  35. sends each variable/library to the kermit server, one by one (it first
  36. checks to see if you have enough memory, though).  They are stored in
  37. files named like:
  38.  
  39.     Lpnnn
  40.  
  41. Where "p" is the port number (0..2), and "nnn" is a number from 1 to
  42. however many variables are in the port.  As each port object is sent to
  43. the server, a note of its type (variable vs library) is made and is
  44. saved away (this is used to restore the backup).  After all port objects
  45. have been saved, the flags are saved in a variable, and an ARCHIVE is
  46. done (the ARCHIVE file name is hard-coded to "BACKUP").  The HP-48SX
  47. will also terminate the kermit server at the end of the backup.
  48.  
  49.      Filename collisions are a problem here.  I strongly suggest
  50. starting the kermit server in an empty directory before starting the
  51. backup.
  52.  
  53.      Here's a summary of the backup process:
  54.  
  55. 1. Make sure the HP-48SX is using wire/binary transfer.
  56.  
  57. 2. Place kermit into SERVER mode.
  58.  
  59. 3. Press BACKUP.  Have a cup of coffee while you wait.  If the suppress
  60.    error beep flag (-56) is not set, the calculator will beep when the
  61.    full backup is complete.
  62.  
  63.      To restore the contents of your HP-48SX, you do the following:
  64.  
  65. 1. Go to the directory containing the backup files.
  66.  
  67. 2. Using kermit, transfer the "backup" archive back to the HP-48SX, and
  68.    RESTORE it.
  69.  
  70. 3. Put kermit into server mode.
  71.  
  72. 4. Go to the HP-48SX directory that contains the BACKUP and RECOVER
  73.    functions.
  74.  
  75. 5. Press RECOVER.  The calculator will transfer the necessary files and
  76.    place the objects into the correct ports.  That's it.
  77.  
  78.  
  79. ***** Known problems:
  80.  
  81. * This program backs up EVERYTHING in RAM (of course, it doesn't touch
  82.   ROM).  It backs up *ALL* libraries, backup objects, other variables,
  83.   etc..  You cannot tell it to not backup something, other than purging
  84.   the object, or pulling the RAM card out of the calculator.
  85.  
  86. * This program is huge, due partly to the extensive checks that makes
  87.   sure that enough memory is present before doing the BACKUP/RECOVER.
  88.   Perhaps these checks should be deleted (but I like having
  89.   user-friendly programs ...)?
  90.  
  91. * No kermit error checking is done.
  92.  
  93. * Currently, some of the constants used to estimate the minimum amount
  94.   of RAM needed are stored in variables ("M" and "S").  Perhaps these
  95.   should be hard-coded?
  96.  
  97. * The current set of functions can be placed anywhere, as long as the
  98.   directory hierarchy is maintained.  Some RAM can be saved if these
  99.   functions were hard-coded to work in a particular directory (such as
  100.   "{HOME BACKUP}").  Does anyone have any preferences?
  101.  
  102. * Does anyone know how to force binary kermit transfers?
  103.  
  104. * I consider this to be a beta-release.  As such, the code is not
  105.   commented.
  106.  
  107.      Extract the program at the end of this message into a file called
  108. "backup", and upload it to your HP-48SX.
  109.  
  110.      -- Darryl Okahata
  111.     UUCP: {hplabs!, hpcea!, hpfcla!} hpnmd!darrylo
  112.     Internet: darrylo%hpnmd@relay.hp.com
  113.  
  114. DISCLAIMER: this message is the author's personal opinion and does not
  115. constitute the support, opinion or policy of Hewlett-Packard or of the
  116. little green men that have been following him all day.
  117.  
  118. ===============================================================================
  119. %%HP: T(3)A(D)F(.);
  120. DIR
  121.   BACKUP
  122.     \<< PATH 0 0 \-> p
  123. sz n
  124.       \<< L
  125.         IFERR
  126. CCHECK
  127.         THEN p EVAL
  128. ERRM DOERR
  129.         END CLLCD
  130. "CHECKING" 4 DISP 0
  131. 2
  132.         FOR p p
  133.           IFERR
  134. PVARS
  135.           THEN DROP
  136. { } ""
  137.           END
  138.           IF TYPE 0
  139. ==
  140.           THEN OBJ\->
  141.             IF DUP
  142. 0 >
  143.             THEN
  144. DUP 'n' STO+ 1 SWAP
  145.               START
  146. RCL BYTES SWAP DROP
  147. IF DUP sz >
  148. THEN 'sz' STO
  149. ELSE DROP
  150. END
  151.               NEXT
  152.             ELSE
  153. DROP
  154.             END
  155.           ELSE DROP
  156.           END
  157.         NEXT
  158.         IF sz DUP
  159. MEM M + n S * + >
  160.         THEN DROP p
  161. EVAL 1 DOERR
  162.         END
  163. 'NEEDED' STO RCLF
  164. 'FLAGS' STO { } DUP
  165. DUP 'PV2' STO 'PV1'
  166. STO 'PV0' STO
  167. OPENIO 0 2
  168.         FOR p p
  169.           IFERR
  170. PVARS
  171.           THEN DROP
  172. { } ""
  173.           END
  174.           IF TYPE 0
  175. ==
  176.           THEN OBJ\->
  177.             IF DUP
  178. 0 >
  179.             THEN 1
  180. SWAP
  181.               FOR i
  182. CLLCD "Port " p +
  183. C$ 3 : " + OVER +
  184. C$ 1 " + 4 DISP
  185. IF DUP OBJ\-> DROP
  186. TYPE 0 \=/
  187. THEN DUP \->STR
  188. ELSE p
  189. END "'PV" p + "'" +
  190. OBJ\-> STO+ RCL "'L"
  191. p + i + "'" + OBJ\->
  192. SWAP OVER STO DUP
  193. SEND CLLCD
  194. "Wait ..." 4 DISP
  195. IF DUP VTYPE 15 ==
  196. THEN PGDIR
  197. ELSE PURGE
  198. END
  199.               NEXT
  200.             ELSE
  201. DROP
  202.             END
  203.           ELSE DROP
  204.           END
  205.         NEXT CLLCD
  206. "Archiving main mem ..."
  207. 4 DISP :IO: BACKUP
  208. ARCHIVE DONE p EVAL
  209.       \>>
  210.     \>>
  211.   RECOVER
  212.     \<< PATH \-> p
  213.       \<< L
  214.         IFERR
  215. CCHECK
  216.         THEN p EVAL
  217. ERRM DOERR
  218.         END
  219.         IF NEEDED
  220. MEM >
  221.         THEN p EVAL
  222. 1 DOERR
  223.         END OPENIO
  224. 0 2
  225.         FOR p "'PV"
  226. p + "'" + OBJ\-> RCL
  227. OBJ\->
  228.           IF DUP 1
  229. \>=
  230.           THEN 1
  231. SWAP
  232.             FOR i
  233. CLLCD \-> n
  234.               \<< "L"
  235. p + i + DUP KGET
  236. "'" DUP ROT + SWAP
  237. + OBJ\-> DUP RCL DUP
  238. IF n TYPE 0 ==
  239. THEN 0 p \->TAG STO
  240. ELSE n OBJ\-> STO
  241. END CLLCD
  242. "Wait ..." 4 DISP
  243. IF TYPE 15 ==
  244. THEN PGDIR
  245. ELSE PURGE
  246. END
  247.               \>>
  248.             NEXT
  249.           ELSE DROP
  250.           END
  251.         NEXT FLAGS
  252. STOF DONE p EVAL
  253.       \>>
  254.     \>>
  255.   M 300
  256.   S 10
  257.   L
  258.     DIR
  259.       FLAGS {
  260. # 3808000400100FF0h
  261. # 0h }
  262.       PV0 { 0 0 }
  263.       PV1 { }
  264.       PV2 { }
  265.       NEEDED 2955
  266.       CCHECK
  267.         \<<
  268.           IF -40
  269. FS?
  270.           THEN -40
  271. CF
  272. "Clock display disabled
  273. Retry operation"
  274. DOERR
  275.           END
  276.         \>>
  277.       DONE
  278.         \<< FINISH
  279. CLOSEIO CLLCD
  280. "DONE" 1 DISP 1
  281. FREEZE
  282.           IF -56
  283. FC?
  284.           THEN 1400
  285. .1 BEEP
  286.           END
  287.         \>>
  288.     END
  289. END
  290.  
  291.  
  292.